package com.saodisheng.controller;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Page;
import com.saodisheng.interceptor.FriendInterceptor;
import com.saodisheng.interceptor.FrontAuthInterceptor;
import com.saodisheng.model.NewsFeed;
import com.saodisheng.service.NewsFeedReplyService;
import com.saodisheng.service.NewsFeedService;
import com.saodisheng.service.ReferMeService;
import com.saodisheng.service.RemindService;
import org.springframework.beans.factory.annotation.Autowired;

@Before({FrontAuthInterceptor.class, FriendInterceptor.class})
public class NewsFeedController extends BaseController {
	@Autowired
	private NewsFeedService srv;
	@Autowired
	private NewsFeedReplyService newsFeedReplyService;
	@Autowired
	private ReferMeService referMeService;
	@Autowired
	private RemindService remindService;
	
	public void referMe() {
		Page<NewsFeed> newsFeedPage = referMeService.paginate(getLoginAccountId(), getParaToInt("p", 1));
		// 重置提醒 remind 的 referMe 字段
		remindService.resetRemindOfReferMe(getLoginAccountId());
		setAttr("newsFeedPage", newsFeedPage);
		// 用于指定重用页面分页宏所使用的 link
		setAttr("paginateLink", "/my/referMe?p=");
		render("index.html");
	}
}
